//
//  VXSqli.m
//  VXiao
//
//  Created by CJ on 14-1-7.
//  Copyright (c) 2014年 hc. All rights reserved.
//

#import "VXSqli.h"

@implementation VXSqli
+(VXSqli *)shareVxsqlit
{
    static VXSqli* sqliet;
    if(!sqliet)
    {
        sqliet=[[VXSqli alloc]init];
        [sqliet getdb];
        [sqliet crentrTable];
    }
    return sqliet;
}
- (FMDatabase *)getdb
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentDirectory = [paths objectAtIndex:0];
    NSString *dbPath = [documentDirectory stringByAppendingPathComponent:@"MyDatabase.db"];
    NSLog(@"%@",dbPath);
    FMDatabase *db=[FMDatabase databaseWithPath:dbPath];
    if (![db open]) {
        NSLog(@"4444");
        return nil;
    }
    else
    {
        _db=db;
        return db;
    }
  
}

- (void)crentrTable
{
    //聊天记录
    [_db executeUpdate:@"CREATE  TABLE  note(senderId INTEGER , recipientId INTEGER ,conte TEXT,vodeLeng TEXT,notedate INTEGER,type INTEGER,id INTEGER PRIMARY KEY)"];
    //好友与最后聊天
    [_db executeUpdate:@"CREATE  TABLE  Friend(MyId INTEGER , FriendId INTEGER ,FriendHead TEXT,FriendName TEXT,Content TEXT,NoteDate INTEGER,NoteTyoe INTEGER,Nuber INTEGER,BName TEXT,XB INTEGER)"];
    //好友请求
    [_db executeUpdate:@"CREATE  TABLE  FriendRequest(MyId INTEGER , FriendId INTEGER ,FriendName TEXT,FriendHead TEXT,Result INTEGER,IsSee INTEGER,requesetDate INTEGER,FRId TEXT)"];
}
@end
